package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Indexed;

import javax.persistence.*;

/**
 * 
 */
@Entity
@Table(name = "travel_rulescope")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class)})
public class RuleScope extends BaseModel {

	private static final long serialVersionUID = -5991997372804649368L;
	
	@Id
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@In
	private Long pkScope;
	
	/** 名称 */
	@Column
	@Field
	private String name;
	
	/** 范围类型*/
	@Enumerated(EnumType.STRING)
	@Field
	@In
	@FieldBridge(impl = EnumBridge.class)
	private ScopeType scopeType;
	
	@JsonSerialize(using = EnumSerializer.class)
	public enum ScopeType {
		Direct("直属旅居养老机构"), Alliance("联盟单位");

		private String display;

		ScopeType(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}
	
	/** 规则类型*/
	@Enumerated(EnumType.STRING)
	@Field
	@In
	@FieldBridge(impl = EnumBridge.class)
	private RuleType ruleType;	
	
	@Version
	private Integer version;

	public Long getPkScope() {
		return pkScope;
	}

	public void setPkScope(Long pkScope) {
		this.pkScope = pkScope;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ScopeType getScopeType() {
		return scopeType;
	}

	public void setScopeType(ScopeType scopeType) {
		this.scopeType = scopeType;
	}

	public RuleType getRuleType() {
		return ruleType;
	}

	public void setRuleType(RuleType ruleType) {
		this.ruleType = ruleType;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
